package com.ls.pattern.prototype.shallow;

import java.util.List;

/**
 * 浅克隆，实现cloneAble接口
 * 浅克隆在复制引用数据类型时，复制的是地址值。在实际业务中会出现风险。
 * 以下用Integer和List进行测试
 *
 * @author 挥之以墨
 */
public class ShallowPersonDTO implements Cloneable {

    private String name;

    private Integer age;

    private List<String> hobbies;

    private PhoneDTO phone;

    private List<PhoneDTO> phones;

    @Override
    public ShallowPersonDTO clone() throws CloneNotSupportedException {
        return (ShallowPersonDTO) super.clone();
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public List<String> getHobbies() {
        return hobbies;
    }

    public void setHobbies(List<String> hobbies) {
        this.hobbies = hobbies;
    }

    public PhoneDTO getPhone() {
        return phone;
    }

    public void setPhone(PhoneDTO phone) {
        this.phone = phone;
    }

    public List<PhoneDTO> getPhones() {
        return phones;
    }

    public void setPhones(List<PhoneDTO> phones) {
        this.phones = phones;
    }
}
